package com.example.b_308.myapplication.view.base;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by B-308 on 2017/11/17.
 */
public abstract class BaseFragment extends Fragment implements IBaseView{
    protected View contentView;
    String title;
    AlertDialog.Builder adBuilder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        contentView = setContentView(inflater);
        init();
        return contentView;
    }

    protected abstract void init();

    protected abstract View setContentView(LayoutInflater inflater);


    public String getTitle() {
        return title;
    }

    public BaseFragment setTitle(String title) {
        this.title = title;
        return this;
    }

    public <T extends View> T findViewById(int resouceId) {
        return (T) contentView.findViewById(resouceId);
    }

    @Override
    public void fail(String message) {
//            弹出一个弹出框
        adBuilder = new AlertDialog.Builder(getContext());
        adBuilder.setTitle("提示");
        adBuilder.setMessage(message);
        adBuilder.setPositiveButton("确定",null);
        adBuilder.show();
    }
    /*boolean selec=false;

    public void setSelec(boolean selec) {
        this.selec = selec;
        if(selec){
            onPageSelect();
        }else {
            onPageUnSelect();
        }
    }*/


    public void onActivityForResoult(int requestCode, int resultCode, Intent data){
    }
}
